<template>
  <div id="app">
    <div v-if="warn">请升级你的浏览器！</div>
    <router-view v-if="!warn"></router-view>
  </div>
</template>

<script>
import config from './utils/config'
// 请升级你的ie浏览器
var warn = false;
function myBrowser() {
  var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
  var isIE =
    userAgent.indexOf("compatible") > -1 &&
    userAgent.indexOf("MSIE") > -1 &&
    !isOpera; //判断是否IE浏览器
  var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
  var isSafari = userAgent.indexOf("Safari") > -1; //判断是否Safari浏览器
  if (isIE) {
    var IE5 = (IE55 = IE6 = IE7 = IE8 = IE9 = false);
    var verIE = new RegExp("MSIE (\\d+\\.\\d+);");
    verIE.test(userAgent);
    var fIEVersion = parseFloat(RegExp["$1"]);
    IE55 = fIEVersion == 5.5;
    IE6 = fIEVersion == 6.0;
    IE7 = fIEVersion == 7.0;
    IE8 = fIEVersion == 8.0;
    IE9 = fIEVersion == 9.0;
    if (IE55) {
      return "IE55";
    }
    if (IE6) {
      return "IE6";
    }
    if (IE7) {
      return "IE7";
    }
    if (IE8) {
      return "IE8";
    }
    if (IE9) {
      return "IE9";
    }
  } //isIE end
  if (isFF) {
    return "FF";
  }
  if (isOpera) {
    return "Opera";
  }
}
//以下是调用上面的函数
var nowBrowser = myBrowser();
if (window.screen.width < 1200) {
  location.href = config.phone_host+"/login"; //屏幕小于1200px时跳转到移动端
} else {
  if (nowBrowser == "FF") {
    // alert("Firefox");
  }
  if (nowBrowser == "Opera") {
    alert("Opera");
  }
  if (nowBrowser == "Safari") {
    alert("Safari");
  }
  if (nowBrowser == "IE55") {
    warn = true;
    // alert("请升级你的IE浏览器");
  }
  if (nowBrowser == "IE6") {
    warn = true;
    // alert("请升级你的IE浏览器");
  }
  if (nowBrowser == "IE7") {
    warn = true;
    // alert("请升级你的IE浏览器");
  }
  if (nowBrowser == "IE8") {
    warn = true;
    // alert("请升级你的IE浏览器");
  }
  if (nowBrowser == "IE9") {
    warn = true;
    // alert("请升级你的IE浏览器");
  }
}

export default {
  name: "app",
  data() {
    return {
      warn: warn,
    };
  },
  components: {},
};
</script>

<style>
</style>
